import http from "./http"
export function loop(number) {
    const url = `/api/weChat/applet/course/banner/list?number=${number}`;
    return http.get(url)
}
//下拉列表封装get请求
export  function list(enable) {
    const url=`/api/weChat/applet/subject/list`
    return http.post(url,{"enable":enable})
}
//课程接口封装post请求
export  function kecheng(type,pageNum,pageSize) {
    let param = new URLSearchParams();
    param.append('pageNum',pageNum)
    param.append('type',type)
    param.append('pageSize',pageSize)
    const url=`/api/weChat/applet/course/list/type`
    return http.post(url,param)
}
//友情链接接口封装post请求
export function youqinglianjie(dictType,pageNum,pageSize,orderByColumn,isAsc){
    let param =new URLSearchParams()
    param.append('dictType',dictType)
    param.append('pageNum',pageNum)
    param.append('pageSize',pageSize)
    param.append('orderByColumn',orderByColumn)
    param.append('isAsc',isAsc)
    const url=`/api/system/dict/data/list/open`
    return http .post(url,param)
}
//课程详情接口封装get请求
export function kechengxiangqing(courseId) {
    const url=`/api/pc/course/detail/${courseId}`
    return http.get(url,{"courseId":courseId})
}
//登录接口封装
export function login(username,password,rememberMe) {
    let params =new URLSearchParams()
    params.append('username',username)
    params.append('password',password)
    params.append('rememberMe',rememberMe)
    const url = '/api/pcUser/login'
    return http.post(url,params)
}
//退出登录接口封装
export function logout() {
    let url = `/api/pcUser/logout`;
    return http.get(url)
}
// 查看登录信息的接口
export function logininfo() {
    return http.get(`/api/pcUser/login-user/info`)
}

// 查看我的购物车 /weChat/applet/shoppingCart/my/list
export function listShoppingCart(status=""){
    let url = `/api/weChat/applet/shoppingCart/my/list?status=${status}`;
    return  http.get(url)
}
//加入购物车的接口
export function addgouwuche(courseId) {
    let url = `/api/weChat/applet/shoppingCart/join/shoppingCart/${courseId}`;
    return  http.get(url,{"courseId":courseId})

}
// 发送验证码
export function codeAuth(mobile) {
    return http.get(`/api/pcUser/login/send/code/${mobile}`)
}
// 手机号登录
export function phoneLogin(mobile, code) {
    let x = new URLSearchParams
    x.append("mobile", mobile)
    x.append("code", code)
    x.append("rememberMe", true)
    return http.post(`/api/pcUser/login/mobile`, x)
}
//修改头像
export function avatar(file) {
    let params = new FormData()
    params.append("file", file)
    return http.post(`/api/pcUser/updata/userAvatar`, params)
}

